package com.example.design.filter.enums;


import com.example.design.ServiceException;
import com.example.design.DataDictionary;

/**
 * 智能排班-排班类型
 */
public enum ScheduleTypeEnum implements DataDictionary {

    PRE_SALE("pre_sale", "售前排班", 2) {
        @Override
        public ScheduleShiftEnum getRestShift() {
            return ScheduleShiftEnum.PRE_SALE_REST;
        }
    },

    AFTER_SALE("after_sale", "售后排班", 1) {
        @Override
        public ScheduleShiftEnum getRestShift() {
            return ScheduleShiftEnum.AFTER_SALE_REST;
        }
    },
    ;

    public abstract ScheduleShiftEnum getRestShift();

    private final String dictCode;
    private final String dictName;
    private final int lowerLimit;

    ScheduleTypeEnum(String dictCode, String dictName, int lowerLimit) {
        this.dictCode = dictCode;
        this.dictName = dictName;
        this.lowerLimit = lowerLimit;
    }

    public static ScheduleTypeEnum getByDictCode(String dictCode) {
        for (ScheduleTypeEnum shiftEnum : ScheduleTypeEnum.values()) {
            if (shiftEnum.getDictCode().equalsIgnoreCase(dictCode)) {
                return shiftEnum;
            }
        }
        throw new ServiceException("未知的排班类型");
    }

    @Override
    public String getDictCode() {
        return dictCode;
    }

    @Override
    public String getDictName() {
        return dictName;
    }

    @Override
    public String getDictItemDesc() {
        return dictCode;
    }

    @Override
    public int intValue() {
        return ordinal();
    }

    public int getLowerLimit() {
        return lowerLimit;
    }
}
